<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <title>总管理后台登录</title>
    <link href="/static/temp/css/login.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="login-page" id="wrapper">
    <div class="form" id="login_form">
        <form class="layui-form">
            <h2>管理员登录</h2>
            <input name="username" placeholder="账号" type="text" autocomplete="off" />
            <input name="password" placeholder="密码" type="password" />
            <button lay-filter="login" id="btn" type="button">登　录</button>
        </form>
    </div>
</div>

<script src="/static/temp/js/jquery.min.js"></script>
<script charset="utf-8" src="/static/temp/layui/layui.js" type="text/javascript"></script>
<script src="/static/temp/js/xadmin.js" type="text/javascript"></script>
<script type="text/javascript">
    $('#btn').click(function(){
        let username = $('input[name=username]').val();
        let password = $('input[name=password]').val();

        $.ajax({
            url:'{:url("login/login")}',
            data:{username:username,password:password},
            type:"post",
            dataType:'json',
            success:function(msg){
                if(msg.code == 200){
                    layer.msg(msg.msg, {icon: 6});
                    setTimeout(function(){
                        window.location.href = '{:url("index/index")}';
                    }, 1000);
                }else{
                    layer.msg(msg.msg, {icon: 2});
                }
            },
        });
    })
</script>
</body>
</html>